//
//  LGSportTrainHeaderView.m
//  XieHeHeartDisease
//
//  Created by 1234 on 2024/2/29.
//

#import "LGSportTrainHeaderView.h"

#define width1  viewPix(72)
#define width2  viewPix(45)
#define width3  viewPix(100)
#define width4  viewPix(115)

@interface LGSportTrainHeaderView()
/**   */
@property (nonatomic , strong)UILabel *dateLabel;
/**   */
@property (nonatomic , strong)UILabel *lengthLabel;
/**   */
@property (nonatomic , strong)UIView *topLine;
/**   */
@property (nonatomic , strong)UIView *lineView1;
/**   */
@property (nonatomic , strong)UIView *lineView2;
/**   */
@property (nonatomic , strong)UIView *lineView3;
/**   */
@property (nonatomic , strong)UIView *lineView4;
/**   */
@property (nonatomic , strong)UIView *lineView5;
/**   */
@property (nonatomic , strong)UIView *lineView6;
/**   */
@property (nonatomic , strong)UIView *lineView7;
/**   */
@property (nonatomic , strong)UIView *lineView8;
/**  用时 */
@property (nonatomic , strong)UILabel *timeLabel;
/**  心率达标 */
@property (nonatomic , strong)UILabel *xldbLabel;
/**  平均心率 */
@property (nonatomic , strong)UILabel *pjxlLabel;
/**  最大心率 */
@property (nonatomic , strong)UILabel *zdxlLabel;
/**  血压 */
@property (nonatomic , strong)UILabel *xyLabel;
/**  症状 */
@property (nonatomic , strong)UILabel *zzLabel;
/**  疲劳程度 */
@property (nonatomic , strong)UILabel *plcdLabel;
/**  呼吸困难 */
@property (nonatomic , strong)UILabel *hxknLabel;

@end

@implementation LGSportTrainHeaderView
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubView];
    }
    return self;
}

-(void)setDateStr:(NSString *)dateStr{
    _dateStr = dateStr;
    self.dateLabel.text = dateStr;
}

-(void)setTimeStr:(NSString *)timeStr{
    _timeStr = timeStr;
    self.lengthLabel.text = [NSString stringWithFormat:@"%@小时",timeStr];
}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    self.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.dateLabel];
    [self addSubview:self.lengthLabel];
    [self addSubview:self.topLine];
    [self addSubview:self.lineView1];
    [self addSubview:self.lineView2];
    [self addSubview:self.lineView3];
    [self addSubview:self.lineView4];
    [self addSubview:self.lineView5];
    [self addSubview:self.lineView6];
    [self addSubview:self.lineView7];
    [self addSubview:self.lineView8];
    [self addSubview:self.timeLabel];
    [self addSubview:self.xldbLabel];
    [self addSubview:self.pjxlLabel];
    [self addSubview:self.zdxlLabel];
    [self addSubview:self.xyLabel];
    [self addSubview:self.zzLabel];
    [self addSubview:self.plcdLabel];
    [self addSubview:self.hxknLabel];
  
    [self.lengthLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-viewPix(12));
        make.centerY.equalTo(self.dateLabel);
    }];

    [self.topLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(viewPix(40));
        make.left.right.equalTo(self);
        make.height.equalTo(@(0.5));
    }];
    [self.lineView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.topLine.mas_bottom);
        make.left.equalTo(self).offset(width1);
        make.bottom.equalTo(self);
        make.width.equalTo(@(0.5));
    }];
    [self.lineView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.width.equalTo(self.lineView1);
        make.left.equalTo(self.lineView1.mas_right).offset(width1);
    }];
    [self.lineView3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.width.equalTo(self.lineView1);
        make.left.equalTo(self.lineView2.mas_right).offset(width1);
    }];
    [self.lineView4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.width.equalTo(self.lineView1);
        make.left.equalTo(self.lineView3.mas_right).offset(width2);
    }];
    [self.lineView5 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.width.equalTo(self.lineView1);
        make.left.equalTo(self.lineView4.mas_right).offset(width2);
    }];
    [self.lineView6 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.width.equalTo(self.lineView1);
        make.left.equalTo(self.lineView5.mas_right).offset(width3);
    }];
    [self.lineView7 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.width.equalTo(self.lineView1);
        make.left.equalTo(self.lineView6.mas_right).offset(width4);
    }];
    [self.lineView8 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.width.equalTo(self.lineView1);
        make.left.equalTo(self.lineView7.mas_right).offset(width2);
    }];
    
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.topLine.mas_bottom);
        make.bottom.equalTo(self);
        make.left.equalTo(self.lineView1.mas_right).offset(viewPix(10));
        make.right.equalTo(self.lineView2.mas_left).offset(-viewPix(10));
    }];
    [self.xldbLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.timeLabel);
        make.left.equalTo(self.lineView2.mas_right).offset(viewPix(10));
        make.right.equalTo(self.lineView3.mas_left).offset(-viewPix(10));
    }];
    [self.pjxlLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.timeLabel);
        make.left.equalTo(self.lineView3.mas_right).offset(viewPix(10));
        make.right.equalTo(self.lineView4.mas_left).offset(-viewPix(10));
    }];
    [self.zdxlLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.timeLabel);
        make.left.equalTo(self.lineView4.mas_right).offset(viewPix(10));
        make.right.equalTo(self.lineView5.mas_left).offset(-viewPix(10));
    }];
    [self.xyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.timeLabel);
        make.left.equalTo(self.lineView5.mas_right).offset(viewPix(10));
        make.right.equalTo(self.lineView6.mas_left).offset(-viewPix(10));
    }];
    
    [self.zzLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.timeLabel);
        make.left.equalTo(self.lineView6.mas_right).offset(viewPix(10));
        make.right.equalTo(self.lineView7.mas_left).offset(-viewPix(10));
    }];
    
    [self.plcdLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.lineView7.mas_right).offset(viewPix(10));
        make.right.equalTo(self.lineView8.mas_left).offset(-viewPix(10));
        make.centerY.equalTo(self.timeLabel);
    }];
    [self.hxknLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.lineView8.mas_right).offset(viewPix(10));
        make.right.equalTo(self).offset(-viewPix(10));
        make.centerY.equalTo(self.timeLabel);
    }];
}

-(UILabel *)dateLabel{
    if(!_dateLabel){
        _dateLabel = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
        _dateLabel.frame = CGRectMake(viewPix(12), 0, viewPix(150), viewPix(40));
    }
    return _dateLabel;
}

-(UILabel *)lengthLabel{
    if(!_lengthLabel){
        _lengthLabel = [UILabel lableWithText:@"" colorString:@"#282828" textFont:LGFont(14) textAlignment:NSTextAlignmentRight lines:1];
    }
    return _lengthLabel;
}

-(UIView *)topLine{
    if(!_topLine){
        _topLine = [[UIView alloc] initWithFrame:CGRectMake(0, 0, Screen_W-viewPix(32), 0.5)];
        _topLine.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _topLine;
}


-(UILabel *)timeLabel{
    if(!_timeLabel){
        _timeLabel = [UILabel lableWithText:@"用时" colorString:@"#606266" textFont:LGFont(12) textAlignment:NSTextAlignmentLeft lines:2];
    }
    return _timeLabel;
}

-(UILabel *)xldbLabel{
    if(!_xldbLabel){
        _xldbLabel = [UILabel lableWithText:@"心率达标时长" colorString:@"#606266" textFont:LGFont(12) textAlignment:NSTextAlignmentLeft lines:2];
    }
    return _xldbLabel;
}

-(UILabel *)pjxlLabel{
    if(!_pjxlLabel){
        _pjxlLabel = [UILabel lableWithText:@"平均心率" colorString:@"#606266" textFont:LGFont(12) textAlignment:NSTextAlignmentLeft lines:2];
    }
    return _pjxlLabel;
}

-(UILabel *)zdxlLabel{
    if(!_zdxlLabel){
        _zdxlLabel = [UILabel lableWithText:@"最大心率" colorString:@"#606266" textFont:LGFont(12) textAlignment:NSTextAlignmentLeft lines:2];
    }
    return _zdxlLabel;
}

-(UILabel *)xyLabel{
    if(!_xyLabel){
        _xyLabel = [UILabel lableWithText:@"血压" colorString:@"#606266" textFont:LGFont(12) textAlignment:NSTextAlignmentLeft lines:2];
    }
    return _xyLabel;
}

-(UILabel *)zzLabel{
    if(!_zzLabel){
        _zzLabel = [UILabel lableWithText:@"症状" colorString:@"#606266" textFont:LGFont(12) textAlignment:NSTextAlignmentLeft lines:2];
    }
    return _zzLabel;
}

-(UILabel *)plcdLabel{
    if(!_plcdLabel){
        _plcdLabel = [UILabel lableWithText:@"疲劳程度" colorString:@"#606266" textFont:LGFont(12) textAlignment:NSTextAlignmentLeft lines:2];
    }
    return _plcdLabel;
}

-(UILabel *)hxknLabel{
    if(!_hxknLabel){
        _hxknLabel = [UILabel lableWithText:@"呼吸困难程度" colorString:@"#606266" textFont:LGFont(12) textAlignment:NSTextAlignmentLeft lines:2];
    }
    return _hxknLabel;
}


-(UIView *)lineView1{
    if(!_lineView1){
        _lineView1 = [[UIView alloc] init];
        _lineView1.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _lineView1;
}

-(UIView *)lineView2{
    if(!_lineView2){
        _lineView2 = [[UIView alloc] init];
        _lineView2.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _lineView2;
}

-(UIView *)lineView3{
    if(!_lineView3){
        _lineView3 = [[UIView alloc] init];
        _lineView3.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _lineView3;
}

-(UIView *)lineView4{
    if(!_lineView4){
        _lineView4 = [[UIView alloc] init];
        _lineView4.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _lineView4;
}

-(UIView *)lineView5{
    if(!_lineView5){
        _lineView5 = [[UIView alloc] init];
        _lineView5.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _lineView5;
}

-(UIView *)lineView6{
    if(!_lineView6){
        _lineView6 = [[UIView alloc] init];
        _lineView6.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _lineView6;
}

-(UIView *)lineView7{
    if(!_lineView7){
        _lineView7 = [[UIView alloc] init];
        _lineView7.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _lineView7;
}

-(UIView *)lineView8{
    if(!_lineView8){
        _lineView8 = [[UIView alloc] init];
        _lineView8.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _lineView8;
}


@end
